<template>
  <!--勘察附件start -->
  <el-dialog
    v-dialogDrag
    :title="dialogTitle"
    :close-on-click-modal="false"
    :visible.sync="dialogVisible"
    class="dialogStyleMiddle"
    :before-close="cancel"
  >
    <el-form
      v-if="dialogVisible"
      ref="addForm"
      class="dialog-form"
      :model="formData"
      label-width="80px"
    >
      <el-row :gutter="20">
        <el-col :span="24">
          <el-form-item label="试验结果" prop="attachId">
            <FileUplode
              ref="fileUplode"
              :edit-file-list="outlineList"
              :is-del="true"
              :status="status"
              @getFileList="getOutline"
            />

          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <DialogFooter />
    </div>
  </el-dialog>
  <!--勘察附件end -->
</template>

<script>
// 页面接口
// import { addProjectFile } from '@/api/basicInfo/projectInfo/project/index'
// 上传文件
import FileUplode from '@/components/Upload/FileUplode'
// dialog-footer
import DialogFooter from '@/components/Common/Btns/DialogFooter/index'
export default {
  components: {
    FileUplode,
    DialogFooter
  },
  data() {
    return {
      /* 新增 start*/
      dialogTitle: '', // 弹层标题
      dialogVisible: false, // 弹层是否显示
      formData: { // 新增数据
        id: '', // 项目id
        attachId: '', // 附件
        outlineList: [],
        outlineListDelete: ''
      },
      status: '',
      /* 新增 end*/
      readOnly: true,
      outlineList: []// 附件
    }
  },
  methods: {
    /* 新增/编辑弹层 start*/
    // 新增/编辑
    handleAdd(id) {
      this.dialogTitle = '查看试验结果'
      this.dialogVisible = true
      if (id) {
        this.getDetailById(id)
      }
    },
    // 查询试验数据的详情
    getDetailById(id) {
      this.formData.attachId = '111'
      this.$nextTick(() => {
        this.outlineList = []
      })
      // getProjectById(id).then(res => {
      //   if (res) {
      //     this.formData = { ...res.data }
    //       if (res.data.attachIdList && res.data.attachIdList.length > 0) {
    //         this.outlineList = res.data.attachIdList
    //       }
      //   }
      // })
    },
    // 取消按钮
    cancel() {
      this.dialogVisible = false
    },
    // 提交按钮
    submitForm() {
      this.$refs['addForm'].validate(valid => {
        if (valid) {
          this.msgSuccess('试验数据通过')
          this.dialogVisible = false
        }
      })
    },
    /* 新增弹层 end*/
    /** ************ 文件上传start *******************/
    getOutline(fileList, deleteFileIds) {
      this.formData.outlineList = fileList
      this.formData.outlineListDelete = deleteFileIds
    }
    /** ************ 文件上传end *******************/
  }

}
</script>

<style>

</style>
